package com.jiyun.springboot_user.controller;
import com.jiyun.springboot_user.core.ResponseResult;
import com.jiyun.springboot_user.entity.User;
import com.jiyun.springboot_user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "login接口")
@RequestMapping("/login")
@Log4j2
public class LoginController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "注册")
    @PostMapping(value = "/add")
    public ResponseResult add(@RequestBody User user){
       return userService.add(user);
    }

    @ApiOperation(value = "登录")
    @PostMapping(value = "/doLogin")
    public ResponseResult login(@RequestBody User user){
        return userService.login(user);
    }


}
